<?php

namespace app\backend\controller;

use app\backend\model\sys_user;
use think\Cache;
use think\Controller;
use think\Request;

class Base extends Controller
{

    protected $beforeActionList = [
        "checkLogin" =>["except"=>"postlogin,login"]
    ];

    public function _initialize()
    {

    }
    // 检查是否登录
    public function checkLogin(){
        $userModel = new sys_user();
        $islogn = $userModel->isLogin();
        if(!$islogn){
            $this->redirect("backend/index/login");
        }
    }
    public function buildSuccess($code, $msg = '操作成功',$data=[]) {
        $return = [
            'code' => $code,
            'msg'  => $msg,
            'data' => $data
        ];
        return $return;
    }

    public function buildFailed($code=0, $msg='', $data = []) {
        $return = [
            'code' => $code,
            'msg'  => $msg,
            'data' => $data
        ];
        return $return;
    }
}
